/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = frxml_update2doc_content.c                                */
/*  NOTE      =                                                    */
/*  DATE      = 2015/03/24     by geyh                             */
/*******************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <libxml/xmlreader.h>
#include <libxml/xpath.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>

#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "frxml_parse.h"
#include "frmem.h"
#include "frcomm.h"
#include "frlist.h"
#include "conntrack.h"
#include "../../comm/apmtest_cunit.h"
#include "../../comm/apmtest_comm.h"


static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

static void __case1(void)
{
    int i_ret = 0;
    char *p_file_name = (char *)"t_frxml_parse/t_frxml_update2doc_content/apm_conf1.xml";
    char *p_tar = (char *)"apm_mempool_size";
    char *p_value = (char *)"10";
    char *xpath = (char *)"/apm_frame";

    system("cp t_frxml_parse/t_frxml_update2doc_content/apm_conf.xml t_frxml_parse/t_frxml_update2doc_content/apm_conf1.xml");
    i_ret = frxml_update2doc_content(p_file_name, xpath, p_tar, p_value);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);

    return;

}

static void __case2(void)
{
    int i_ret = 0;
    char *p_file_name = (char *)"t_frxml_parse/t_frxml_update2doc_content/apm_conf2.xml";
    char *p_tar = (char *)"report_lib";
    char *p_value = (char *)"../report1/report1_1.0.so";
    char *xpath = (char *)"/apm_frame/report";

    system("cp t_frxml_parse/t_frxml_update2doc_content/apm_conf.xml t_frxml_parse/t_frxml_update2doc_content/apm_conf2.xml");
    i_ret = frxml_update2doc_content(p_file_name, xpath, p_tar, p_value);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);

    return;

}

static void __case3(void)
{
    int i_ret = 0;
    char *p_file_name = (char *)"t_frxml_parse/t_frxml_update2doc_content/apm_conf3.xml";
    char *p_tar = (char *)"test";
    char *p_value = (char *)"test";
    char *xpath = (char *)"/apm_frame";

    system("cp t_frxml_parse/t_frxml_update2doc_content/apm_conf.xml t_frxml_parse/t_frxml_update2doc_content/apm_conf3.xml");
    i_ret = frxml_update2doc_content(p_file_name, xpath, p_tar, p_value);

    CU_ASSERT_EQUAL(i_ret,FR_FAIL);

    return;

}

int add_suite_frxml_update2doc_content(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frcomm frxml_update2doc_content()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);


    return FR_SUCC;
}